import { useEffect } from 'react';
import {  useSelector, useDispatch } from 'umi'



export default function Home() {
  const num = useSelector((state:any) => state.count.num);
  const cates = useSelector((state:any) => state.count.cates);
  const dispatch = useDispatch();

  useEffect(() => {
    dispatch({
      type: 'count/getCates',
      params: {
        page: 1,
        pageSize: 10
      }
    })
  }, [])
  return (
    <div>
      首页
      <button onClick={
        () => {
          dispatch({
            type: 'count/add',
            data: 5
          })
        }
      }>+</button>
      {num}

      <ul>
        {
          cates.map((cate:any) => (
            <li key={cate.id}>
              {cate.name}
              <img src={cate.icon} width={100} alt="" />
            </li>
          ))
        }
       
      </ul>
    </div>
  )
}

